/*
 * @Author: wanglei 554623567@qq.com
 * @Date: 2024-10-24 10:28:06
 * @LastEditors: wanglei
 * @LastEditTime: 2024-10-26 12:28:48
 * @FilePath: /forstep/lib/common/utils/string_utils.dart
 * @Description: 字符串处理
 */

import 'dart:math';

class StringUtil {
  /// 生成指定长度的随机字符串，只包含字母（a-z, A-Z）和数字（0-9）
  static String generateRandomString(int length) {
    const String chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    final Random random = Random();
    return String.fromCharCodes(Iterable.generate(length, (_) => chars.codeUnitAt(random.nextInt(chars.length))));
  }
}
